package com.haitaoit.chengquan.business.data;

import android.content.Context;
import android.os.Handler;

import com.google.gson.Gson;
import com.haitaoit.chengquan.business.http.QLResponseCall;
import com.haitaoit.chengquan.business.http.bean.ParamObj;
import com.haitaoit.chengquan.module.center.model.MyAddressModel;
import com.haitaoit.chengquan.utils.AppLog;
import com.haitaoit.chengquan.utils.Constant;

import java.util.List;

/**
 * ClassName:设置默认地址
 * author: Cocoa
 * date: 2016/9/28.
 */

public class SetDefaultAddressHttp extends BaseHttp {
    private Handler handler;
    private int            what;
    private boolean        isShowProgress;
    private String url= Constant.Getupdate_user_address_default;
    private List<ParamObj> paramObjs;

    public SetDefaultAddressHttp(Context context, Handler handler, List<ParamObj> paramObjs, int what, boolean isShowProgress) {
        this.context = context;
        this.handler = handler;
        this.what = what;
        this.paramObjs = paramObjs;
        this.isShowProgress = isShowProgress;
        start();
    }

    private void start() {
        AppLog.D("url:" + url+getParamObjsToString(paramObjs));
        getHttp().get(url+getParamObjsToString(paramObjs), new QLResponseCall() {
            @Override
            public void onStart() {
                if (isShowProgress)
                    onStartHandler(handler);
            }

            @Override
            public void onFailure(String arg0, int error) {
                AppLog.D("onFailure:" + error);
                AppLog.D("onFailure:" + arg0);
                onFailureHandler(context, handler, arg0, error);
            }

            @Override
            public void onSuccess(String result) {
                AppLog.D("result:" + result);
                onSuccessHandler(context, handler, result);
            }
        });
    }

    @Override
    void getData(Handler handler, BaseDataResp responseObj) {
        sendHandler(handler, null, what);
    }
}
